package customlists;

import java.util.ArrayList;

import model.GroupContacts;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ContactsCustomListAdapter extends BaseAdapter {

	private ArrayList<GroupContacts> contactResults;
	private LayoutInflater mInflater;
	Context context;
	
	public ContactsCustomListAdapter(Context applicationContext,
			ArrayList<GroupContacts> contactsList) {
		contactResults=contactsList;
		mInflater = LayoutInflater.from(applicationContext);
		this.context=applicationContext;
	}

	public int getCount() {
		return contactResults.size();
	}

	public Object getItem(int position) {
		return contactResults.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if(convertView==null){
			holder = new ViewHolder();
			convertView =mInflater.inflate(phone.book.R.layout.contactslistview, null);
			holder.img=(ImageView) convertView.findViewById(phone.book.R.id.contactimage);
			holder.contactsName=(TextView) convertView.findViewById(phone.book.R.id.contactslist);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder) convertView.getTag();
		}
		holder.contactsName.setText(contactResults.get(position).getContactName());
		return convertView;
	}
	static class ViewHolder {
		  ImageView img;
		  TextView contactsName;
	}

}
